﻿using System;
using System.Web;
using System.Web.Security;

/// <summary>
/// Summary description for Global
/// </summary>
public class Global : HttpApplication {

    #region Methods ///////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Initializes the memebership.
    /// </summary>
    void InitMemebership() {

        string[] roles = Roles.GetAllRoles();
        if (roles == null || roles.Length == 0) {
            Roles.CreateRole("Administrators");
        }

        MembershipUserCollection users = Membership.GetAllUsers();
        if (users == null || users.Count == 0) {
            Membership.CreateUser("admin", "admin", "admin@test.com");
            Roles.AddUserToRole("admin", "Administrators");
        }
    }
    #endregion

    #region Wireups ///////////////////////////////////////////////////////////////////////////////

    void Application_Start(object sender, EventArgs e) {
        InitMemebership();
    }

    void Application_End(object sender, EventArgs e) {
    }

    void Application_Error(object sender, EventArgs e) {
    }

    void Session_Start(object sender, EventArgs e) {
    }

    void Session_End(object sender, EventArgs e) {
    }
    #endregion
}
